﻿package game.network.api.fb.data{

	public class FQLMultiQuery {

		public var queries:Object;

		public function FQLMultiQuery () {
			queries = {};
		}

		public function add (query:String, name:String, values:Object = null):void {
			if (queries.hasOwnProperty(name)) {
				throw new Error("Query name already exists, there cannot be duplicate names");
			}

			for (var n:String in values) {
				query = query.replace(new RegExp('\\{'+n+'\\}', 'g'), values[n]);
			}

			queries[name] = query;
		}

		public function toString ():String {
			return JSON.stringify(queries);
		}
	}
}